import category_encoders as ce
import pandas as pd

df = pd.DataFrame({
    'ID' : [1,2,3,4,5,6],
    'RATING':['G','B','G','B','B','G']
})
#编码类别变量
encoder = ce.BinaryEncoder(cols=['RATING']).f